/* 
 * File:        packetContents.h
 * Authors:     Jonathan Kotker (ee122-bw) and Shaan Mulchandani (ee122-bv)
 * Description: This header file contains a struct that describes
 *              the contents of a packet.
 */

#include "constants.h"

#ifndef _PACKETCONTENTS_H
#define	_PACKETCONTENTS_H

typedef struct {

    /* Message type; uses the 'messages' enum in "constants.h". */
    enum messages messageType;

    /* 'Attacker name' in ATTACK_NOTIFY packets. */
    char attackerName[EE122_MAX_NAME_LENGTH + 1];

    /* 'Victim name' in ATTACK packets,
     * 'Player name' in LOGIN_REQUEST packets,
     * 'Player name' in MOVE_NOTIFY packets,
     * 'Broadcaster name' in SPEAK_NOTIFY packets,
     * 'Player name' in LOGOUT_NOTIFY packets. */
    char victimName[EE122_MAX_NAME_LENGTH + 1];

    /* 'Error code' in LOGIN_REPLY packets,
     * 'Error code' in INVALID_STATE packets. */
    char errorCode;

    /* 'HP' in LOGIN_REPLY packets,
     * 'HP' in MOVE_NOTIFY packets. */
    signed long int hp;

    /* 'EXP' in LOGIN_REPLY packets,
     * 'EXP' in MOVE_NOTIFY packets. */
    signed long int exp;

    /* 'Direction' in MOVE packets. */
    enum direction moveDir;

    /* 'X Location' in MOVE_NOTIFY packets. */
    short int xLoc;

    /* 'Y Location' in MOVE_NOTIFY packets. */
    short int yLoc;

    /* 'Damage' in ATTACK_NOTIFY packets. */
    char damage;

    /* 'Message' in SPEAK packets,
     * 'Message' in SPEAK_NOTIFY packets. */
    char message[EE122_MAX_MSG_LENGTH + 1];

    /* Length of packet (in bytes). */
    int length;

    /* Flag to notify any malformed packets. */
    int flag;

} packetContents;

#endif	/* _PACKETCONTENTS_H */
